package com.infocollect.project.api.ui;

import com.infocollect.project.api.entity.TappPorcessinsEntity;
import com.infocollect.project.api.req.QueryPorcessInsListReq;
import com.infocollect.project.api.service.ITappCommonNoService;
import com.infocollect.project.api.service.ITappPorcessinsService;
import com.infocollect.project.api.vo.HandleProcessVO;
import com.infocollect.project.form.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

/**
 * (TappPorcessins)表控制层
 *
 * @author makejava
 * @since 2019-12-25 10:32:29
 */
@Api(value = "processins", tags = "流程实例ID")
@RestController
@RequestMapping("processins")
public class TappPorcessinsController {


    @Resource
    private ITappCommonNoService tappCommonnoService;
    /**
     * 服务对象
     */
    @Resource
    private ITappPorcessinsService tappPorcessinsService;
    /**
     * 服务对象
     */
    @Resource
    private com.infocollect.project.api.service.IProcessHandleService IProcessHandleService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TappPorcessinsEntity selectOne(Long id) {
        return this.tappPorcessinsService.queryById(id);
    }

    /**
     * 处理流程入口
     *
     * @return
     */
    @PostMapping("HandleProcess")
    @ResponseBody
    public R<Long> HandleProcess(@RequestBody HandleProcessVO param) throws Exception {
        return IProcessHandleService.HandleProc( param);

    }

    @ApiOperation("获取当前用户所有相关的流程列表数据")
    @PostMapping("/queryporcessinsList")
    @ResponseBody
    public R<List<TappPorcessinsEntity>> queryporcessinsList(@RequestBody QueryPorcessInsListReq param) {
        return tappPorcessinsService.queryporcessinsList(param);
    }

    @ApiOperation("生成单号")
    @GetMapping("/getprocinstnumber")
    @ResponseBody
    public R<String> GetProcInstNumber(@RequestParam(value = "bMoudleEN", defaultValue = "") String bMoudleEN, @RequestParam(value = "bModuleID", defaultValue = "") String bModuleID) throws IOException {
        return R.newOk(tappCommonnoService.GetProcInstNumber(bMoudleEN, bModuleID));
    }


}